<?php

namespace app\api\utils;

class jsonResult
{
    static public function result($code, $message = null, $data = null, $count = null): \think\response\Json
    {
        $result = array(
            'code' => $code,
        );
        if ($message !== null) {
            $result['message'] = $message;
        }
        if ($data !== null) {
            $result['data'] = $data;
        }
        if ($count !== null) {
            $result['count'] = $count;
        }

        return json($result);
    }

}
